package com.wcs.exam.controller.api;

import com.wcs.exam.common.base.Result;
import com.wcs.exam.common.base.page.Page;
import com.wcs.exam.controller.api.biz.ApiExamBiz;
import com.wcs.exam.controller.api.req.ApiExamPageReq;
import com.wcs.exam.controller.api.req.ApiExamRankPageReq;
import com.wcs.exam.controller.api.resp.ApiExamPageResp;
import com.wcs.exam.controller.api.resp.ApiExamRankPageResp;
import com.wcs.exam.controller.api.resp.ApiExamViewResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * Api-考试
 *
 * @author wcs
 * @since 2025-03-13
 */
@Tag(name = "Api-考试")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/api/exam")
public class ApiExamController {

    @NotNull
    private final ApiExamBiz biz;

    @Operation(summary = "考试搜索")
    @GetMapping(value = "/search")
    public Result<Page<ApiExamPageResp>> search(@ModelAttribute ApiExamPageReq req) {
        return biz.search(req);
    }

    @Operation(summary = "考试详情")
    @Parameter(name = "id", description = "考试ID", required = true)
    @GetMapping(value = "/view")
    public Result<ApiExamViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @Operation(summary = "考试-考试排行榜-分页", description = "考试-考试排行榜-分页")
    @GetMapping(value = "/rank/page")
    public Result<Page<ApiExamRankPageResp>> rankPage(@ModelAttribute @Valid ApiExamRankPageReq req) {
        return biz.rankPage(req);
    }

}
